package com.hengpeng.itfinoss.util;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class ConfigUtil
{
	private static final Log logger = LogFactory.getLog(ConfigUtil.class);

	private static final Properties properties = new Properties();

	private static final String filePath = "hp-common.properties";

	private static String decodeUrl = null;

	static
	{

		InputStream inStream = null;
		try
		{
			decodeUrl = java.net.URLDecoder.decode(ConfigUtil.class.getResource("/").getPath(), "utf-8") + filePath;
			inStream = new FileInputStream(decodeUrl);
			properties.load(inStream);
		}
		catch (IOException e)
		{
			e.printStackTrace();
			logger.error("系统配置文件{" + decodeUrl + "}装载失败");
		}
	}

	public static String getConfigValue(String key)
	{
		return properties.getProperty(key);
	}

	public static void setConfigValue(String key, String value)
	{
		properties.setProperty(key, value);
	}
}
